package cn.javaxc.mvcwork.util.common;



import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import com.ruoyi.common.core.domain.model.LoginUser;

import java.util.ArrayList;
import java.util.List;


public class MSecurityUtils {
	


	public static Authentication getSubject() {
		return SecurityContextHolder.getContext().getAuthentication();
	}
	
	public static LoginUser getUserEntity() {
		return (LoginUser)getSubject().getPrincipal();
	}

	public static Object getUserId() {
		return getUserEntity().getUser().getUserId();
	}
	
//	public static void setSessionAttribute(Object key, Object value) {
//		getSession().setAttribute(key, value);
//	}

//	public static Session getSession() {
//		return SecurityUtils.getSubject().getSession();
//	}
//	public static Object getSessionAttribute(Object key) {
//		return getSession().getAttribute(key);
//	}




//	public static int getRoleId(){
//        Subject sy = getSubject();
//	    Integer count = -1;
//        if(sy.hasRole(Constants.ADMIN_ACC)){
//            count = 1;
//        }
//        if(sy.hasRole(Constants.SECOND_ACC)){
//            count = 2;
//        }else if(sy.hasRole(Constants.THREE_ACC)){
//            count = 3;
//        }
//        return count;
//    }
}
